/*
 * IJA2011, Board game "Clovece nezlob se"
 * grp108
 * Tomáš Mičiak,xmicia00
 * Andrej Martinák, xmarti51
 *
 */

package src.clovece.game;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.ImageIcon;
import javax.swing.JLabel;

/**
 *  Class representing human player
 */
public class Player extends JLabel implements MouseListener {
    protected GameManagement gameManagement = GameManagement.getGameManagementInstance();
    protected GameInfo gameInfo = GameInfo.getGameInfoInstance();
    protected String nickname = null;
    protected boolean userControled = false;
    protected Figurine[] figurines = new Figurine[4];
    protected int position;
    protected boolean onTurn;


    public Player() {
        super();
    }

    public Player(int gameSet, int figurine, int number, String nickname) {
        super(nickname);
        this.nickname = nickname;
        this.position = number;
        ImageIcon icon = new ImageIcon(System.getProperty("user.dir")+ System.getProperty("file.separator")
                  + "lib" + System.getProperty("file.separator") + "img"
                  + System.getProperty("file.separator") + "house.png");
        this.setIcon(icon);
        this.setVerticalTextPosition(JLabel.TOP);
        this.setHorizontalTextPosition(JLabel.CENTER);
        int x = 0;
        int y = 0;
        
        if(number == 0) {x = 100; y = 70;}
        if(number == 1) {x = 590; y = 540;}
        if(number == 2) {x = 590; y = 70;}
        if(number == 3) {x = 100; y = 540;}
        this.setBounds(x, y, 115, 115);
        
        for(int i = 0; i < 4; i++) {
            if(i == 0) y += 25;
            if(i == 0) x += 5;
            this.figurines[i] = new Figurine(gameSet,figurine,i,this);
            this.figurines[i].setBounds(x, y, 40, 40);
            this.figurines[i].addMouseListener(this.figurines[i]);
            if(i == 0) x += 40;
            if(i == 1) y += 40;
            if(i == 2) x -= 40;
            if(i == 3) y -= 40;
        }
    }

    public void setPosition(int p) {
        this.position = p;
    }

    public int getPosition() {
        return this.position;
    }

    public void setOnTurn(boolean flag) {
        this.onTurn = flag;
    }

    public boolean getOnTurn() {
        return this.onTurn;
    }

    public void setUserControled(boolean flag) {
        this.userControled = flag;
    }

    public boolean getUserControled() {
        return this.userControled;
    }

    public void setNickname(String name) {
        this.nickname = name;
    }

    public String getNickname() {
        return this.nickname;
    }

    public void setFigurines(Figurine[] f) {
        this.figurines = f;
    }

    public Figurine[] getFigurines() {
        return this.figurines;
    }

    public void mouseClicked(MouseEvent e) {
        System.out.println("Check out for mice!");
    }

    public void mousePressed(MouseEvent e) {
    }

    public void mouseReleased(MouseEvent e) {
    }

    public void mouseEntered(MouseEvent e) {
    }

    public void mouseExited(MouseEvent e) {
    }

}
